package com.ruoyi.app.W.mapper;

import com.ruoyi.app.W.domain.advice;
import com.ruoyi.app.zzq.domain.Partydues;
import com.ruoyi.app.zzq.domain.User;
import com.ruoyi.project.system.domain.SysNotice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * @Author sa
 **/
@Mapper
public interface WMapper {

  @Select("select * from partydues where partyId=#{userId} and partyDuesStatus=1")
  List<Partydues> selectPartyDues(Integer userId);

  @Select("select * from sys_notice where status = '2' and status='0' and notice_id =#{noticeId}")
  List<SysNotice>  notices(String id);

//  @Select("select * from sys_notice where notice_type = '2' and status='0'")
  @Select("select * from sys_notice where notice_type = '2' and status='0'" +
          " and cp_id=" + "(select dept_id from sys_user where user_id=#{userId})")
  List<SysNotice> SelectCurrNotice(Integer userId);


  @Insert("insert into advice ( launchPartyId, adviceTitle, adviceContent, adviceTime," +
          " advicePhoto,acceptPartyId,adviceDelete) values (#{launchPartyId},#{adviceTitle},#{adviceContent},#{adviceTime},#{advicePhoto},#{acceptPartyId},#{adviceDelete})")
  Boolean SubmitAdvice(advice advice);

  @Select("select dept_id, pdept_id from sys_user where user_id=#{userId}")
  User showAcceptPartyIds(String userId);

  @Select("select dept_name from sys_dept where dept_id=#{deptId}")
  String SelectDeptName(String deptId);
  @Select("select * from advice where launchPartyId=#{launchPartyId} and adviceDelete=0 "
  )
  List<advice> SelectmyAdvice(String launchPartyId);

  @Select("select * from advice")
  List<advice> SelectAllAdvice();

  @Update("update  advice set adviceContent=#{adviceContent},advicePhoto=#{advicePhoto}," +
          "adviceTitle=#{adviceTitle}, adviceTime=#{adviceTime},acceptPartyId=#{acceptPartyId} where adviceId=#{adviceId} and replyStatus=0 and adviceDelete=0")
  boolean UpdatemyAdvice(advice advice);
  @Update("update  advice set adviceDelete=1 where adviceId=#{adviceId}")
  boolean DeletemyAdvice(Integer adviceId);
  @Select("select partyDuesStatus from partydues where partyId=#{userId} ")
  int SelectIfPays(Integer userId);
  @Select("select pdept_id from sys_user where user_id=#{userId}")
  String selectCommunityId(String userId);
  @Select("select * from sys_notice where status = '1' and cp_id=#{CommunityId}")
  List<SysNotice> SelectMyComNotice(String CommunityId);

//@Select("select * from sys_notice where notice_type = '1' and status='0' order by create_time  limit 3  ")
@Select("select * from sys_notice where notice_type = '1' and status='0'" +
        " and cp_id=" + "(select pdept_id from sys_user where user_id=#{userId})"+" order by create_time  limit 3  ")
  List<SysNotice> SelectCarousele(Integer userId);


  @Update("UPDATE  partyDues SET payingTime=#{payingTime},partyDuesStatus=0 where partyDuesStatus=1 and partyId=#{userId}")
  boolean MyPayTydue(Date payingTime, Integer userId);
  @Select("select * from advice where adviceId=#{adviceId} ")
  advice selectActive(Integer adviceId);
}